# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#

MSRC:=time.c
MOBJ:=	asctime.o asctime_r.o clock.o ctime.o ctime_r.o gmtime.o gmtime_r.o \
	localtime.o localtime_r.o mktime.o strftime.o strptime.o tzset.o \
	_time_t2tm.o __time_tm.o _time_mktime.o dysize.o timegm.o \
	_time_mktime_tzi.o _time_localtime_tzi.o
MOBJx:=

ifeq ($(UCLIBC_HAS_FLOATS),y)
MOBJ+=difftime.o 
endif
ifeq ($(UCLIBC_HAS_XLOCALE),y)
MOBJx:=strftime_l.o strptime_l.o
endif

ifeq ($(UCLIBC_HAS_WCHAR),y)
MOBJ+=wcsftime.o
ifeq ($(UCLIBC_HAS_XLOCALE),y)
MOBJx+=wcsftime_l.o
endif
endif

CSRC:=adjtime.c ftime.c

MISC_TIME_DIR:=$(top_srcdir)libc/misc/time
MISC_TIME_OUT:=$(top_builddir)libc/misc/time

MISC_TIME_NO_MULTI:=strftime.o mktime.o strptime.o gmtime.o localtime.o asctime.o asctime_r.o gmtime_r.o localtime_r.o

MISC_TIME_SRC:=$(patsubst %.c,$(MISC_TIME_DIR)/%.c,$(CSRC))
MISC_TIME_OBJ:=$(patsubst %.c,$(MISC_TIME_OUT)/%.o,$(CSRC))

MISC_TIME_MSRC:=$(patsubst %.c,$(MISC_TIME_DIR)/%.c,$(MSRC))
MISC_TIME_MOBJ:=$(patsubst %.o,$(MISC_TIME_OUT)/%.o,$(MOBJ))
MISC_TIME_MOBJx:=$(patsubst %.o,$(MISC_TIME_OUT)/%.o,$(MOBJx))

MISC_TIME_DEF:=$(patsubst %,-DL_%,$(subst .o,,$(filter-out $(MISC_TIME_NO_MULTI),$(notdir $(MISC_TIME_MOBJ)))))

MISC_TIME_OBJS:=$(MISC_TIME_OBJ) $(MISC_TIME_MOBJ)

$(MISC_TIME_MOBJ): $(MISC_TIME_MSRC)
	$(compile.m)

$(MISC_TIME_MOBJ:.o=.os): $(MISC_TIME_MSRC)
	$(compile.m)

$(MISC_TIME_MOBJx): $(MISC_TIME_MSRC)
	$(compile.m) -D__UCLIBC_DO_XLOCALE

$(MISC_TIME_MOBJx:.o=.os): $(MISC_TIME_MSRC)
	$(compile.m) -D__UCLIBC_DO_XLOCALE

libc-a-y+=$(MISC_TIME_OBJS)
libc-a-$(UCLIBC_HAS_XLOCALE)+=$(MISC_TIME_MOBJx)
libc-so-y+=$(MISC_TIME_OBJS:.o=.os)
libc-so-$(UCLIBC_HAS_XLOCALE)+=$(MISC_TIME_MOBJx:.o=.os)

CFLAGS-multi-y+=$(MISC_TIME_DEF)
libc-multi-y+=$(MISC_TIME_MSRC)
libc-nomulti-y+=$(patsubst %.o,$(MISC_TIME_OUT)/%.o,$(MISC_TIME_NO_MULTI))
libc-nomulti-$(UCLIBC_HAS_XLOCALE)+=$(MISC_TIME_MOBJx)

objclean-y+=misc_time_objclean

misc_time_objclean:
	$(RM) $(MISC_TIME_OUT)/*.{o,os}
